-
Notifications
You must be signed in to change notification settings - Fork 651
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use is_recording flag in flask, django, tornado, boto, botocore instrumentations #1164
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the change, it looks pretty good. Please add the changelogs and I've added some comments in the review.
@@ -91,6 +91,8 @@ def collect_request_attributes(scope): | |||
|
|||
def set_status_code(span, status_code): | |||
"""Adds HTTP response attributes to span using the status_code argument.""" | |||
if not span.is_recording(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if it's worth adding a decorator as a convenience
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possibly? I think the repetitive-ness of this task just seems obvious because we just didn't do it in the beginning. However, new instrumentations should be respecting this anyways, so I don't think it's that much overhead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was thinking a decorator may help folks building future instrumentations group all the actions that should not occur when a span is not recording more cleanly 🤷♂️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That would be nice. There are some instrumentations that have some interim steps that always must be regardless of is_recording (which occur between some set_attr... methods). A decorator would be difficult to use in those cases.
...pentelemetry-instrumentation-botocore/src/opentelemetry/instrumentation/botocore/__init__.py
Show resolved
Hide resolved
.../opentelemetry-instrumentation-django/src/opentelemetry/instrumentation/django/middleware.py
Show resolved
Hide resolved
...tation/opentelemetry-instrumentation-boto/src/opentelemetry/instrumentation/boto/__init__.py
Show resolved
Hide resolved
I don't believe these needs CHANGELOG entries because they it's not really affecting the user. |
I was thinking the change in behaviour might be unexpected (if anyone was setting is_recording to false and still seeing attributes), though I guess it would have been surprising for this to behave this way in the first place. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving, I can go either ways on the update to the change logs, and I'm not blocking on the decorator.
attributes = collect_request_attributes(environ) | ||
for attr in self._traced_request_attrs: | ||
value = getattr(request, attr, None) | ||
if value is not None: | ||
attributes[attr] = str(value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@owais created a nifty utils function that you can use like this
attributes = collect_request_attributes(environ) | |
for attr in self._traced_request_attrs: | |
value = getattr(request, attr, None) | |
if value is not None: | |
attributes[attr] = str(value) | |
attributes = collect_request_attributes(environ) | |
attributes = extract_attributes_from_object( | |
request, self._traced_request_attrs, attributes | |
) |
It's still in PR though so no need to use it if this is ready first.
Part of #1057